package com.cn.api;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//
//import com.cn.service.sys.TokenService;
//import com.cn.service.sys.UserService;
import com.cn.utils.FormSubmitResult;
import com.cn.utils.validator.Assert;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

/**
 * API登录授权
 *
 */
@RestController
@RequestMapping("/api")
@Api("登录接口")
public class ApiLoginController {
//	@Resource(name = "userService")
//    private UserService userService;
//    @Autowired
//    private TokenService tokenService;

    /**
     * 登录
     */
    @PostMapping("login")
    @ApiOperation(value = "登录",notes = "登录说明")
    @ApiImplicitParams({
        @ApiImplicitParam(paramType = "query", dataType="string", name = "mobile", value = "手机号", required = true),
        @ApiImplicitParam(paramType = "query", dataType="string", name = "password", value = "密码", required = true)
    })
    public FormSubmitResult login(String mobile, String password){
        Assert.isBlank(mobile, "手机号不能为空");
        Assert.isBlank(password, "密码不能为空");

        //用户登录
//        long userId = userService.login(mobile, password);

        //生成token
//        Map<String, Object> map = tokenService.createToken(userId);

        
        return FormSubmitResult.SUCCESS(new HashMap());
    }

}
